package lianxi;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.DBUtil;

public class _06_ {

	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Connection connection = DBUtil.getConnection();
		String sql = "select o.id,o.name,price,order_id,addr,g.name from t_order o,t_goods g";
		PreparedStatement preparedStatement = connection.prepareStatement(sql);
		ResultSet resultSet = preparedStatement.executeQuery(sql);
		while (resultSet.next()) {
			System.out.print(resultSet.getInt("id") + " ");
			System.out.print(resultSet.getString("name") + " ");
			System.out.print(resultSet.getDouble("price") + " ");
			System.out.print(resultSet.getInt("order_id") + " ");
			System.out.print(resultSet.getString("addr") + " ");
			System.out.println(resultSet.getString("g.name"));
		}
		DBUtil.close(preparedStatement);
		DBUtil.close(connection);
		DBUtil.close(resultSet);
	}

}
